package org.example;

public class Test3 {
    public String reverseWords(String s) {
        s = s.trim();
        String[] arr = s.split("\\s+");
        int left = 0, right = arr.length-1;
        while (left < right) {
            String tmp = arr[left];
            arr[left] = arr[right];
            arr[right] = tmp;
            left++;
            right--;
        }
        return String.join(" ",arr);
    }

    public static void main(String[] args) {
        Test3 test3 = new Test3();
        test3.reverseWords("a good   example");
        System.out.println(666);
    }
}
